home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Archive / Graphics / QuickDraw GX / IW-Half-Dither / source / OldApp.c < prev    next >
Encoding:
Text File  |  2000-09-28  |  18.5 KB  |  677 lines  |  [TEXT/MPS ]

  1. /*
  2.     copyright © 1992-1994 Apple Computer Inc.  All rights reserved.
  3.     
  4.     OldApp.c
  5.     This file implements old application message overrides for the specific driver.
  6.     
  7.     Included in this file is the old PrintRecord emulation.  Note that the ImageWriter
  8.     PrintRecord is a wonder of misdirection and special cases.  You'll have fun
  9.     figuring out the code - so unless you really want to exactly emulate the ImageWriter
  10.     pages, you shouldn't spend too much time looking at this code.
  11.     
  12.     Modification history
  13.     7/23/92            TED                New file today
  14.     12/20/93        dmh                Sync'd with the shipping 1.0b3 GX driver.
  15.      8/26/94        dmh                Sync'd with the shipping 1.0.1 GX driver.
  16.  
  17. */
  18.  
  19. // Include the standard Mac header files 
  20. #include <Errors.h>
  21. #include <ToolUtils.h>
  22. #include <StdIO.h>
  23. #include <StdLib.h>
  24. #include <String.h>
  25. #include <Strings.h>
  26. #include <Resources.h>
  27. #include <ToolUtils.h>
  28. #include <OSUtils.h>
  29. #include <Files.h>
  30. #include <Types.h>
  31. #include <Packages.h>
  32. #include <Memory.h>
  33. #include <Serial.h>
  34. #include <Devices.h>
  35. #include <Fonts.h>
  36. #include <Printing.h>
  37. #include <Script.h>
  38. #include <Events.h>
  39. #include <Dialogs.h>
  40. #include <FixMath.h>
  41. #include <Lists.h>
  42. #include <AppleTalk.h>
  43. #include <Menus.h>
  44. #include <Events.h>
  45. #include <Balloons.h>
  46. #include <Folders.h>
  47. #include <SCSI.h>
  48.  
  49. // Include the new QuickDraw GX graphics header files 
  50. #include <GXGraphics.h>
  51. #include <GXMath.h>
  52. #include <QDLibrary.h>
  53. #include <FontLibrary.h>
  54. #include <GXLayout.h>
  55. #include <GraphicsLibraries.h>
  56.  
  57. // Include the required Printing Manager header files 
  58. #include <GXPrinting.h>
  59. #include <GXPrinterDrivers.h>
  60. #include <CollectionLibrary.h>
  61. #include <JobFormatModeLibrary.h>
  62. #include <PaperTypeLibrary.h>
  63. #include <PicturesAndPICTLibrary.h>
  64. #include <Collections.h>
  65. #include <GXMessages.h>
  66.  
  67. #include "CommonDefines.h"            // things common to .r and .h files
  68. #include "DriverProtos.h"
  69.  
  70. #if defined(__MWERKS__)
  71.     asm void __Startup__(void);
  72.     asm void __Startup__(void)
  73.     {
  74.         dc.l    0                    // Reserved for owner count.
  75.  
  76.         jmp        SD_ConvertPrintRecordTo
  77.         jmp        SD_ConvertPrintRecordFrom
  78.         jmp        SD_PrintRecordToJob
  79.         jmp        SD_PrValidate
  80.         jmp        SD_PrJobInit
  81.  
  82.         RTS                            // this is needed so __Startup__ symbol works
  83.     }
  84. #endif
  85.  
  86.  
  87. /* ----------------------------------------------------------------------------    */
  88. /* INTERNAL TYPEDEFS AND STRUCTURES                                                */
  89. /* ----------------------------------------------------------------------------    */
  90. // ImageWriter wDev values
  91. #define kBest            0x01
  92. #define kPortrait        0x02
  93. #define kTallAdjusted    0x04
  94. #define k50Percent        0x08
  95. #define kNoGaps            0x10
  96. #define kSetResCalled    0x20
  97.  
  98. // some ImageWriter constants
  99. #define kGapSize        60        // gap at top of page in 120ths of an inch
  100. #define kSmallPlaten    16        // platen width in half inches for small IW
  101. #define kBigPlaten        27        // platen width in half inches for the 15" IW
  102.  
  103. /* ----------------------------------------------------------------------------    */
  104. /* FORWARD DECLARES                                                                */
  105. /* ----------------------------------------------------------------------------    */
  106. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint);
  107. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint);
  108.  
  109.  
  110. /* ----------------------------------------------------------------------------    */
  111. /* INTERNAL ROUTINES                                                            */
  112. /* ----------------------------------------------------------------------------    */
  113. OSErr    UpdatePrintRecord(THPrint hPrint)
  114. {
  115.     OSErr                        anErr;
  116.     gxUniversalPrintRecordHdl     huPrint = (gxUniversalPrintRecordHdl)hPrint;
  117.     gxUniversalPrintRecordPtr     puPrint;
  118.     short                        devVRes, devHRes, appVRes, appHRes;
  119.     short                        cPlaten;
  120.     
  121.     // convert to universal format
  122.     anErr = SD_ConvertPrintRecordTo(hPrint);
  123.     if (anErr == noErr)
  124.         {
  125.         // determine application & device resolutions, based upon quality mode, tall adjusted
  126.         // setting, and if the app called SetRsl:
  127.         //    draft - 80(h)*72(v)
  128.         //    faster - 80(h)*72(v)
  129.         //    best - 160(h)*144(v)
  130.         //
  131.         //    draft (tall adjusted) - 72*72
  132.         //    faster (tall adjusted) - 72*72
  133.         //    best (tall adjusted) - 144*144
  134.         
  135.         puPrint = *huPrint;
  136.         if (puPrint->options & gxPreciseBitmap)
  137.             switch(puPrint->qualityMode)
  138.                 {
  139.                 case gxDraftQuality:
  140.                 case gxFasterQuality:
  141.                     devVRes = devHRes = 72;
  142.                     appVRes = appHRes = 72;
  143.                     break;
  144.                     
  145.                 case gxBestQuality:
  146.                     devVRes = devHRes = 144;
  147.                     appVRes = appHRes = 72;
  148.                     break;
  149.                 }
  150.         else
  151.             switch(puPrint->qualityMode)
  152.                 {
  153.                 case gxDraftQuality:
  154.                 case gxFasterQuality:
  155.                     appVRes = devVRes = 72;
  156.                     appHRes = devHRes = 80;
  157.                     break;
  158.                     
  159.                 case gxBestQuality:
  160.                     devVRes = 144;
  161.                     devHRes = 160;
  162.                     appVRes = 72;
  163.                     appHRes = 80;
  164.                     break;
  165.                 }
  166.             
  167.         // SetRsl was called?  Use the resolution specified by the application
  168.         if (puPrint->appVRes != 72)
  169.             {
  170.             appVRes = devVRes = puPrint->appVRes;
  171.             appHRes = devHRes = puPrint->appHRes;
  172.             }
  173.             
  174.         // finally, store the app & device resolutions
  175.         puPrint->devVRes = devVRes;
  176.         puPrint->devHRes = devHRes;
  177.         puPrint->appVRes = appVRes;
  178.         puPrint->appHRes = appHRes;
  179.         
  180.         // here we do page size calculations
  181.         // Please note that this code is confusing - it's purpose is to emulate
  182.         // the existing ImageWriter driver's page size.  Most drivers would not
  183.         // do this - the existing in the system probably is good enough.
  184.         {
  185.         long        pageGap;                // gap at top of page
  186.         long        dvPaper, dhPaper;        // paper size at device res
  187.         long        dvPage, dhPage;            // page size at device res
  188.         long        scanLines, scanBits;    // # of scan lines or bits on page
  189.         long        maxH;                    // maximum width
  190.         long        hOff, vOff;                // margins (horiz & vert) to get paper rect from page rect
  191.         
  192.         // gap at the top of the page in pixels
  193.         pageGap = (kGapSize * appVRes) / 120;
  194.         if (puPrint->options & gxBiggerPages)
  195.             pageGap = 0;
  196.             
  197.         // figure out paper size in application space pixels
  198.         dvPaper = (puPrint->pageV * appVRes) / 120;
  199.         dhPaper = (puPrint->pageH * appHRes) / 120;
  200.                 
  201.         // vertically, align to the head height of 8 pixels
  202.         scanLines = ((dvPaper - pageGap) >> 3) << 3;
  203.         
  204.         // horizontally, allow the biggest width we can handle
  205.         cPlaten = kSmallPlaten;
  206.         if (puPrint->pageH > (9*120) )
  207.             cPlaten = kBigPlaten;
  208.             
  209.         maxH = (cPlaten * appHRes) >> 1;
  210.         if (maxH > dhPaper)
  211.             maxH = dhPaper;
  212.         scanBits = (maxH >> 4) << 4;
  213.         
  214.         if (puPrint->orientation == gxPortraitOrientation)
  215.             {
  216.             // portrait
  217.             
  218.             dhPage = scanBits;
  219.             dvPage = scanLines;
  220.             
  221.             hOff = (dhPage - dhPaper) >> 1;
  222.             vOff = -pageGap;
  223.             }
  224.         else
  225.             {
  226.             // landscape
  227.             
  228.             dhPage = scanLines;
  229.             dvPage = scanBits;
  230.             
  231.             // reverse the paper definition as well
  232.             {
  233.             long iTemp = dhPaper;
  234.             dhPaper = dvPaper;
  235.             dvPaper = iTemp;
  236.             }
  237.             
  238.             hOff = -pageGap;
  239.             vOff = (dvPage - dvPaper) >> 1;
  240.             }
  241.             
  242.         // 50% reduction?  scale everything by 2X
  243.         if (puPrint->options & gxUserFlag0)
  244.             {
  245.             dhPage <<= 1;
  246.             dvPage <<= 1;
  247.             dhPaper <<= 1;
  248.             dvPaper <<= 1;
  249.             hOff <<= 1;
  250.             vOff <<= 1;
  251.             }
  252.             
  253.         // set the page and paper in app space
  254.         puPrint->appPage.left         = puPrint->appPage.top = 0;
  255.         puPrint->appPage.right         = dhPage;
  256.         puPrint->appPage.bottom     = dvPage;
  257.         
  258.         puPrint->appPaper.left         = hOff;
  259.         puPrint->appPaper.top         = vOff;
  260.         puPrint->appPaper.right     = dhPaper + hOff;
  261.         puPrint->appPaper.bottom     = dvPaper + vOff;
  262.                 
  263.         // from page, scale up to device space (in case some weenie decides to look at that)
  264.         puPrint->devPage.left         = puPrint->devPage.top = 0;
  265.         puPrint->devPage.right         = dhPage * devHRes / appHRes;
  266.         puPrint->devPage.bottom     = dvPage * devVRes / appVRes;
  267.         }
  268.         
  269.         // convert back to non-universal format
  270.         anErr = SD_ConvertPrintRecordFrom((gxUniversalPrintRecordHdl) hPrint);
  271.         }
  272.         
  273.     return(anErr);
  274.     
  275. } // UpdatePrintRecord
  276.  
  277. //<FF>
  278. /* ----------------------------------------------------------------------------    */
  279. /* MESSAGE OVERRIDES                                                            */
  280. /* ----------------------------------------------------------------------------    */
  281. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint)
  282. /*
  283.     This call takes a print record in old style (driver specific) format, and
  284.     converts it to the format of "gxUniversalPrintRecordHdl"
  285. */
  286. {
  287.     TPPrint                        poPrint;            // pointer to old style print record
  288.     gxUniversalPrintRecordHdl    huPrint = (gxUniversalPrintRecordHdl)hoPrint;    // handle to universal print record
  289.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  290.     short                        qualityMode;        // cached quality mode
  291.     short                        wDev;                // cached wDev
  292.     
  293.     // cache pointers for size and speed
  294.     puPrint = *huPrint;
  295.     poPrint = *hoPrint;
  296.     wDev = poPrint->prStl.wDev;
  297.     
  298.     // determine quality mode
  299.     if (poPrint->prJob.bJDocLoop == 0)
  300.         qualityMode = gxDraftQuality;
  301.     else
  302.         {
  303.         if (wDev & kBest)
  304.             qualityMode = gxBestQuality;
  305.         else
  306.             qualityMode = gxFasterQuality;
  307.         }
  308.         
  309.     // universal feed is the inverse of our feed
  310.     puPrint->feed            =    1-(poPrint->prStl.feed);
  311.     
  312.     // wDev 0x02 means portrait, else landscape
  313.     if (wDev & kPortrait) 
  314.         puPrint->orientation    =    gxPortraitOrientation;
  315.     else
  316.         {
  317.         puPrint->orientation    =    gxLandscapeOrientation;
  318.         
  319.         // landscape disabled draft, forces tall adjusted
  320.         if (qualityMode == gxDraftQuality)
  321.             qualityMode = gxFasterQuality;
  322.         wDev |= kTallAdjusted;
  323.         }
  324.         
  325.     // copies are in iCopies field (wow.)
  326.     puPrint->actualCopies        =    poPrint->prJob.iCopies;
  327.     
  328.     // store our flags
  329.     puPrint->options = 0;
  330.     
  331.     // tall adjusted
  332.     if (wDev & kTallAdjusted) 
  333.         puPrint->options |= gxPreciseBitmap;
  334.         
  335.     // 50% reduction
  336.     if (wDev & k50Percent) 
  337.         {
  338.         puPrint->options |= gxUserFlag0;
  339.         puPrint->reduction = 50;
  340.         
  341.         // for 50% reduction, we always return faster to the application
  342.         qualityMode = gxFasterQuality;
  343.         }
  344.     else
  345.         puPrint->reduction = 100;
  346.         
  347.     // no gaps
  348.     if (wDev & kNoGaps) 
  349.         puPrint->options |= gxBiggerPages;
  350.     
  351.     // finally, store quality mode    
  352.     puPrint->qualityMode = qualityMode;
  353.     
  354.     // and we can't have any errors - because this code is too godlike.
  355.     return(noErr);
  356.     
  357. } // SD_ConvertPrintRecordTo
  358.  
  359. //<FF>
  360. /* ----------------------------------------------------------------------------    */
  361. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint)
  362. /*
  363.     This call takes a print record in universal format and converts it
  364.     to old style (driver specific) format.
  365.     
  366.     Note: for the ImageWriter, I'm filling in way more things than theoretically
  367.     I need to.  However, since the ImageWriter is one of the oldest print drivers,
  368.     there is much more of a chance that someone assumes something about one or
  369.     more of the fields.
  370. */
  371. {
  372.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  373.     THPrint                        hoPrint = (THPrint)huPrint;    // handle to old style print record
  374.     TPPrint                        poPrint;            // pointer to old style print record
  375.     short                        options;            // cached universal options
  376.     short                        qualityMode;        // cached universal quality mode
  377.     short                        actualCopies;        // cached universal copies
  378.     
  379.     // cache pointers for size and speed
  380.     puPrint = *huPrint;
  381.     poPrint = *hoPrint;
  382.  
  383.     // save away fields within the universal record that we'll be stomping over
  384.     // as we convert
  385.     options         = puPrint->options;
  386.     qualityMode     = puPrint->qualityMode;
  387.     actualCopies    = puPrint->actualCopies;
  388.     
  389.     poPrint->iPrVersion            = 4;        // used to be 3, but this is
  390.                                             // a new driver.  We support versions
  391.                                             // 3 and 4
  392.     poPrint->prInfo.iDev        = 0;        // always zero for the ImageWriter
  393.     
  394.     // skip remaining fields in prInfo because they are unchanged
  395.     
  396.     // determine the wDev
  397.     {
  398.     short    wDev;
  399.     
  400.     // this is the wDev value for the ImageWriter
  401.     wDev = 0x0100;
  402.     
  403.     if (puPrint->orientation == gxPortraitOrientation)
  404.         wDev |= kPortrait;
  405.     else
  406.         {
  407.         // for landscape, disable draft and force tall adjusted
  408.         if (qualityMode == gxDraftQuality)
  409.             qualityMode = gxFasterQuality;
  410.             
  411.         options |= gxPreciseBitmap;
  412.         }
  413.     
  414.     // user options
  415.     if (options & gxPreciseBitmap)
  416.         wDev |= kTallAdjusted;
  417.     if (options & gxUserFlag0)
  418.         {
  419.         wDev |= k50Percent;
  420.         qualityMode = gxFasterQuality;
  421.         }
  422.  
  423.     if (options & gxBiggerPages)
  424.         wDev |= kNoGaps;
  425.         
  426.     // if the application's resolution isn't 72 - then clearly SetRsl must have been called
  427.     // to change it.
  428.     if (poPrint->prInfo.iVRes != 72)
  429.         {
  430.         wDev |= kSetResCalled;
  431.         qualityMode = gxBestQuality;
  432.         }
  433.         
  434.     if (qualityMode == gxBestQuality)
  435.         wDev |= kBest;
  436.         
  437.         
  438.     // and finally, save away that short value we worked so hard to determine
  439.     poPrint->prStl.wDev = wDev;
  440.     }
  441.  
  442.     // other fields in prStl remain the same
  443.     
  444.     poPrint->prStl.bPort     = 0;
  445.     poPrint->prStl.feed     = 1 - (puPrint->feed);
  446.     poPrint->prInfoPT.iDev     = (qualityMode == gxBestQuality) ? -768 : 0;
  447.  
  448.     // other fields in prInfoPT remain the same
  449.     {
  450.     Rect    rPage = poPrint->prInfoPT.rPage;
  451.     
  452.     // calculate some fields we don't use - in case someone really wants to look at
  453.     // them for some reason
  454.     poPrint->prXInfo.iRowBytes    = rPage.right >> 3;
  455.     poPrint->prXInfo.iBandV        = 32;
  456.     poPrint->prXInfo.iBandH        = poPrint->prXInfo.iRowBytes << 3;
  457.     poPrint->prXInfo.iDevBytes    = poPrint->prXInfo.iRowBytes * 
  458.                                     poPrint->prXInfo.iBandV + 
  459.                                     poPrint->prXInfo.iBandH;
  460.     poPrint->prXInfo.iBands        = (rPage.bottom+(poPrint->prXInfo.iBandV-1)) / poPrint->prXInfo.iBandV;
  461.     poPrint->prXInfo.bPatScale     = (qualityMode == gxBestQuality) ? -2 : 0;
  462.     poPrint->prXInfo.bUlThick     = 1;
  463.     poPrint->prXInfo.bUlOffset     = 1;
  464.     poPrint->prXInfo.bUlShadow     = 1;
  465.     poPrint->prXInfo.scan        = (poPrint->prStl.wDev & kPortrait) ? 0 : 2;
  466.     poPrint->prXInfo.bXInfoX    = 0;
  467.     }
  468.     
  469.     // other fields in prJob remain the same
  470.     poPrint->prJob.iCopies        = actualCopies;
  471.     poPrint->prJob.bJDocLoop    = (qualityMode == gxDraftQuality) ? 0 : 1;
  472.     
  473.     // this routine is so studly, there can be no errors
  474.     return(noErr);    
  475.     
  476. } // SD_ConvertPrintRecordFrom
  477.  
  478.  
  479. //<FF>
  480. /* ----------------------------------------------------------------------------    */
  481. OSErr SD_PrintRecordToJob(THPrint hPrint, gxJob theJob)
  482. /*
  483.     We convert the "tall adjusted" setting into the correct rendering option for
  484.     the job collection.
  485. */
  486. {
  487.     OSErr    anErr;
  488.     Handle     jobQualitySettingsHdl;    
  489.     
  490.     anErr = Forward_GXPrintRecordToJob(hPrint, theJob);
  491.     if (anErr == noErr)
  492.         {
  493.         long imagewriterOptions = kSuperRes;
  494.         
  495.         if ((**hPrint).prStl.wDev & kSetResCalled)
  496.             {
  497.             Collection            jobCollection = GXGetJobCollection(GXGetJob());
  498.             gxQualityInfo        *qualitySettings;
  499.     
  500.  
  501.             // get old info and replace it with final quality
  502.  
  503.  
  504.             jobQualitySettingsHdl = NewHandle(0);
  505.             anErr = MemError();
  506.             nrequire(anErr, FailedNewHandle);
  507.  
  508.             anErr = GetCollectionItemHdl (     jobCollection,
  509.                                                 gxQualityTag,
  510.                                                  gxPrintingTagID,
  511.                                                jobQualitySettingsHdl );
  512.  
  513.             if (anErr == collectionItemNotFoundErr) 
  514.                 {
  515.                 Str255            bestString, roughString;
  516.                 Size            count1, count2;
  517.                 Ptr                p;
  518.                 short            curResFile = CurResFile();
  519.                 
  520.                 UseResFile(GXGetMessageHandlerResFile());
  521.                 GetIndString( bestString, kOldQualityID, kBestString);
  522.                 GetIndString( roughString, kOldQualityID, kRoughString);
  523.                 UseResFile(curResFile);
  524.  
  525.                 SetHandleSize(jobQualitySettingsHdl,(sizeof(gxQualityInfo) + bestString[0] + roughString[0] + 2 ));
  526.                 anErr = MemError();
  527.                 nrequire( anErr, FailedSetHandleSize );
  528.                         
  529.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  530.                 
  531.                 qualitySettings->disableQuality = false;
  532.                 qualitySettings->defaultQuality = 1;
  533.                 qualitySettings->currentQuality = 1;
  534.                 qualitySettings->qualityCount = 2;
  535.         
  536.                 count1 = bestString[0]+1;
  537.                 p = qualitySettings->qualityNames;
  538.                 BlockMove( bestString, p, count1 );
  539.         
  540.                 count2 = roughString[0]+1;
  541.                 p += count1;
  542.                 BlockMove( roughString, p, count2 );
  543.         
  544.                 }
  545.             else
  546.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  547.  
  548.             (qualitySettings->currentQuality = qualitySettings->qualityCount-1);
  549.  
  550.             anErr = AddCollectionItemHdl (     jobCollection,
  551.                                             gxQualityTag,
  552.                                             gxPrintingTagID,
  553.                                             jobQualitySettingsHdl );
  554.                                                  
  555.             if (anErr == noErr)
  556.                 (void) SetCollectionItemInfo(jobCollection, gxQualityTag, gxPrintingTagID, 0x0000FFFF, gxVolatileOutputDriverCategory);
  557.                 
  558.             DisposHandle(jobQualitySettingsHdl);
  559.             }
  560.  
  561.         if ((**hPrint).prStl.wDev & kTallAdjusted)
  562.             imagewriterOptions = 0;
  563.             
  564.         if (anErr == noErr)
  565.             anErr = AddCollectionItem(GXGetJobCollection(theJob), 
  566.                         DriverCreator,
  567.                         0,
  568.                         sizeof(imagewriterOptions),
  569.                         &imagewriterOptions);
  570.         }
  571.  
  572. FailedNewHandle:        
  573.     return(anErr);
  574.  
  575. FailedSetHandleSize:
  576.     DisposHandle(jobQualitySettingsHdl);
  577.     return(anErr);
  578.     
  579. } // SD_PrintRecordToJob
  580.  
  581. //<FF>
  582. /* ----------------------------------------------------------------------------    */
  583. OSErr SD_PrValidate(    THPrint hPrint,                 // old style print record
  584.                         Boolean *wasChanged)            // was the print record changed?
  585. /*
  586.     This call validates the current print record.  It's fairly simplistic (as were
  587.     all of the old drivers) - the wDev or versions don't match the current, we call
  588.     PrintDefault.  Otherwise, we call UpdatePrintRecord - to allow the driver to sanity
  589.     check any internal fields.
  590.     
  591. */
  592. {
  593.     unsigned short    wDev;                        // note: if this were signed, the shift below would fail                    
  594.     Boolean            recordIsInvalid = true;            
  595.     OSErr            anErr = noErr;
  596.     
  597.     // check the wDev.  The upper byte must be equal to our idea of the wDev
  598.         
  599.     wDev =  (**hPrint).prStl.wDev;    
  600.     wDev >>= 8;                                // get just the device ID
  601.  
  602.     // If the device id is equal, then check the version number of the print record.
  603.     //    Only if that is also equal to the current version, will we return false (valid).
  604.         
  605.     if (     (wDev == 1) 
  606.         &&
  607.             (
  608.             ( ((**hPrint).iPrVersion) == 3 ) ||
  609.             ( ((**hPrint).iPrVersion) == 4 ) 
  610.             )
  611.         )
  612.         recordIsInvalid = false;
  613.             
  614.  
  615.     // If the the print record is not valid, then return the default print record.
  616.     // Otherwise, update the print record, based on the application's calls
  617.     // to PrGeneral.
  618.         
  619.     if (recordIsInvalid)
  620.         PrintDefault(hPrint);
  621.     else
  622.         anErr = UpdatePrintRecord(hPrint);
  623.         
  624.     *wasChanged = recordIsInvalid;
  625.     
  626.     return (anErr);
  627.     
  628. } // SD_PrValidate
  629.  
  630. //<FF>
  631. /* ----------------------------------------------------------------------------    */
  632. OSErr SD_PrJobInit(THPrint hPrint, TPPrDlg * pDlg)
  633. /*
  634.     This routine is called to initialize the job dialog.  We take the default
  635.     behavior - and then disable some of the items based on settings the user
  636.     has made:
  637.         - 50% disables all items
  638.         - apps that call SetRsl disable all items
  639.         - landscape disables draft mode
  640. */
  641. {
  642.     OSErr    anErr;
  643.     
  644.     anErr = Forward_GXPrJobInit(hPrint, pDlg);
  645.     if (anErr == noErr)
  646.         {
  647.         Boolean    disableDraft     = false;
  648.         Boolean    disableAll         = false;
  649.         short    wDev             = (**hPrint).prStl.wDev;
  650.         short    idx;
  651.         Rect    box;
  652.         Handle    item;
  653.         short    type;
  654.         
  655.         if (wDev & k50Percent)
  656.             disableAll = true;
  657.             
  658.         if (wDev & kSetResCalled)
  659.             disableAll = true;
  660.             
  661.         if (!(wDev & kPortrait))
  662.             disableDraft = true;
  663.         
  664.         // disable any controls we need to
  665.         for (idx = 6; idx <= 8; ++idx)
  666.             {
  667.             GetDItem((DialogPtr) *pDlg, idx, &type, &item, &box);
  668.             
  669.             if ( (disableAll) || ((disableDraft) && (idx == 8) ) )
  670.                 HiliteControl((ControlHandle) item, 255);
  671.             
  672.             }
  673.         }
  674.  
  675.     return(anErr);
  676.     
  677. } // SD_PrJobInit